/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author freis
 */
@Entity
@Table(name = "funcionarios")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Funcionarios.findAll", query = "SELECT f FROM Funcionarios f"),
    @NamedQuery(name = "Funcionarios.findByIdFuncionario", query = "SELECT f FROM Funcionarios f WHERE f.idFuncionario = :idFuncionario"),
    @NamedQuery(name = "Funcionarios.findByNomeFuncionario", query = "SELECT f FROM Funcionarios f WHERE f.nomeFuncionario = :nomeFuncionario"),
    @NamedQuery(name = "Funcionarios.findByDataNascimento", query = "SELECT f FROM Funcionarios f WHERE f.dataNascimento = :dataNascimento"),
    @NamedQuery(name = "Funcionarios.findByEmail", query = "SELECT f FROM Funcionarios f WHERE f.email = :email"),
    @NamedQuery(name = "Funcionarios.findByNif", query = "SELECT f FROM Funcionarios f WHERE f.nif = :nif"),
    @NamedQuery(name = "Funcionarios.findByBi", query = "SELECT f FROM Funcionarios f WHERE f.bi = :bi"),
    @NamedQuery(name = "Funcionarios.findByMorada", query = "SELECT f FROM Funcionarios f WHERE f.morada = :morada"),
    @NamedQuery(name = "Funcionarios.findByTelefone", query = "SELECT f FROM Funcionarios f WHERE f.telefone = :telefone")})
public class Funcionarios implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idFuncionario")
    private Integer idFuncionario;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nomeFuncionario")
    private String nomeFuncionario;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataNascimento")
    @Temporal(TemporalType.DATE)
    private Date dataNascimento;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nif")
    private int nif;
    @Basic(optional = false)
    @NotNull
    @Column(name = "bi")
    private int bi;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 300)
    @Column(name = "morada")
    private String morada;
    @Basic(optional = false)
    @NotNull
    @Column(name = "telefone")
    private int telefone;
    @JoinColumn(name = "Funcoes_idFuncoes", referencedColumnName = "idFuncoes")
    @ManyToOne(optional = false)
    private Funcoes funcoesidFuncoes;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "funcionariosidFuncionario")
    private Collection<Contas> contasCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "funcionariosidFuncionario")
    private Collection<Accoes> accoesCollection;

    public Funcionarios() {
    }

    public Funcionarios(Integer idFuncionario) {
        this.idFuncionario = idFuncionario;
    }

    public Funcionarios(Integer idFuncionario, String nomeFuncionario, Date dataNascimento, String email, int nif, int bi, String morada, int telefone) {
        this.idFuncionario = idFuncionario;
        this.nomeFuncionario = nomeFuncionario;
        this.dataNascimento = dataNascimento;
        this.email = email;
        this.nif = nif;
        this.bi = bi;
        this.morada = morada;
        this.telefone = telefone;
    }

    public Integer getIdFuncionario() {
        return idFuncionario;
    }

    public void setIdFuncionario(Integer idFuncionario) {
        this.idFuncionario = idFuncionario;
    }

    public String getNomeFuncionario() {
        return nomeFuncionario;
    }

    public void setNomeFuncionario(String nomeFuncionario) {
        this.nomeFuncionario = nomeFuncionario;
    }

    public Date getDataNascimento() {
        return dataNascimento;
    }

    public void setDataNascimento(Date dataNascimento) {
        this.dataNascimento = dataNascimento;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getNif() {
        return nif;
    }

    public void setNif(int nif) {
        this.nif = nif;
    }

    public int getBi() {
        return bi;
    }

    public void setBi(int bi) {
        this.bi = bi;
    }

    public String getMorada() {
        return morada;
    }

    public void setMorada(String morada) {
        this.morada = morada;
    }

    public int getTelefone() {
        return telefone;
    }

    public void setTelefone(int telefone) {
        this.telefone = telefone;
    }

    public Funcoes getFuncoesidFuncoes() {
        return funcoesidFuncoes;
    }

    public void setFuncoesidFuncoes(Funcoes funcoesidFuncoes) {
        this.funcoesidFuncoes = funcoesidFuncoes;
    }

    @XmlTransient
    public Collection<Contas> getContasCollection() {
        return contasCollection;
    }

    public void setContasCollection(Collection<Contas> contasCollection) {
        this.contasCollection = contasCollection;
    }

    @XmlTransient
    public Collection<Accoes> getAccoesCollection() {
        return accoesCollection;
    }

    public void setAccoesCollection(Collection<Accoes> accoesCollection) {
        this.accoesCollection = accoesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFuncionario != null ? idFuncionario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Funcionarios)) {
            return false;
        }
        Funcionarios other = (Funcionarios) object;
        if ((this.idFuncionario == null && other.idFuncionario != null) || (this.idFuncionario != null && !this.idFuncionario.equals(other.idFuncionario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Funcionarios[ idFuncionario=" + idFuncionario + " ]";
    }
    
}
